<!DOCTYPE html>
<style id='second'>
#limited {
    color: green;
}
</style>
<script>
if (window.testRunner)
    testRunner.waitUntilDone();

function runTest() {
    // Create font-face
    var font = new FontFace('myahem', 'url(../../resources/Ahem.ttf)', {});
    document.fonts.add(font);

    // Create dummy stylesheet. StyleInvalidationAnalysis will find
    // that no setNeedsStyleRecalc is required.
    var newStyle = document.createElement('style');
    newStyle.innerHTML = '#dummy { color: red; }';

    // Wait until scheduled styleRecalc is finished.

    setTimeout(function() {
        // Insert a new StyleSheet to invoke clearStyleResolver.
        var referenceNode = document.getElementById('second');
        referenceNode.parentNode.insertBefore(newStyle, referenceNode);
        // Load a font while StyleResolver is missing.
        font.load();

        // Wait until scheduled styleRecalc is finished.
        setTimeout(function() {
            if (window.testRunner)
                testRunner.notifyDone();
        }, 0);
    }, 0);
}

onload = function() {
    // Need to runTest when document.parsing is false.
    setTimeout(runTest, 0);
}
</script>
<div id='limited'></div>
<div style='font-family: myahem'>
Test for crbug.com/369401: if fonts are loaded while StyleResolver is missing, the fonts are not rendered.
</div>
